import { treeToArray } from '@/utils/menu.js'
import { getMenu  } from '@/api/login.js'
import Vue from 'vue';
// import isIEBrowser from '@/utils/isIe'


const user = {
    namespaced :true,
      state: {
        baseInfo:{
            userName: '',
            companyName:'',
            departName:'',
        }, 
        getedRouteList: false,
        // children 是null就没有孩子
        routeTreeToList: [],
        routeList: [],
        btnList: [],
        topLoadingStatus: false
      },
      mutations: {
        muGetedRouteList(state, val) {
            state.getedRouteList = val
        },
        muRouteListHandler(state, val) {
            state.routeList = val
        },
        muBtnList(state, val) {
            state.btnList = val
        },
        muRouteTreeToList(state, val) {
            state.routeTreeToList = val
        },
        muBaseInfo(state, val) {
            state.baseInfo = val
        },
        muLoadingStatus(state, val = false) {
            if(val === state.topLoadingStatus){
                return
            }
            state.topLoadingStatus = val
        },
      },
      actions:{
        getRouteList({ commit, state }, payload){
            return new Promise(async (resolve,reject)=>{
                let d = {
                    // pageNo:1,
                    // pageSize:20,
                    // rdid: 84555,
                    // allMerge: true,
                    // mergeMode:"1",
                    // mergeQueryCondition:"1",
                    // rdids:"2,3",
                }
                // let { data,code ,message } = await getMenu(d);

                // if(code ==200){
                //     // 当前 URL 的查询参数字符串
                //     if (window.location.href.indexOf('token') !== -1) {
                //         window.location.replace(process.env.VUE_APP_BASEURL+'/home');
                //     }
                // }
            })
        }

      }
    }
    
    export default user

    
 